<%@page import="java.text.SimpleDateFormat"%>
<%@page import="Board.BoardMyba"%>
<%@page import="Board.BoardVo"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("utf-8");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CLAMP</title>
<script>
	function view(bo_no,part,nowPage) {
		var la = document.getElementById("fi").value;
		
		location.href = 'index.jsp?inc_content=./board/board_view.jsp&bo_part='+part+'&bo_no='
				+ bo_no+'&nowPage='+nowPage+"&text_find="+la;
		/*part값이 필요할때....? bo_part='+part+'&*/
	}

	function PageWrite(part){
		location.href = 'index.jsp?inc_content=./board/board_insert.jsp&bo_part='+part;
	}
	
	function gonji_li(bo_no,part,nowPage){
		var la = document.getElementById("fi").value;
		location.href = 'index.jsp?inc_content=./board/board_view.jsp&bo_part='+part+'&bo_no='
		+ bo_no+'&nowPage='+nowPage+"&text_find="+la;
	}

	
	
	function search(part, page) {
		var s = document.getElementById("fi").value;
		var ff = document.paging;
		ff.action = 'index.jsp?inc_content=./board/board_list.jsp&bo_part='+part+'&text_find='+s+'&nowPage='+1;
		ff.submit();
	}
	function goPage(part,page) {
		/* alert(part);
		alert(page); */
		var ff = document.paging;
		ff.action = 'index.jsp?inc_content=./board/board_list.jsp&bo_part='+part+'&nowPage='+page;
		ff.submit();
	}
	
	
	
</script>
<style>
/*리스트*/
#board_view {
	width: 900px;
	margin: 0 auto;
	text-align: center;
	border-bottom: 1px dotted #dddddd;
	border-top: 2px solid #dddddd;
	padding-top: 5px;
	padding-bottom: 5px;
	font-size: 10pt;
	vertical-align: middle;
}
/*맨 아랫줄 solid임시로 줘보기.*/
/*#board_bottom{
	width:900px;
	height:15px;
	margin : 0 auto;
	border-bottom: 2px solid #dddddd;
}*/
#board_gubun {
	width: 10%;
	display: inline-block;
}

#board_main {
	width: 40%;
	display: inline-block;
}

#board_mid {
	width: 10%;
	display: inline-block;
}

#board_peo_view {
	width: 10%;
	display: inline-block;
}

#board_date {
	width: 20%;
	display: inline-block;
}

/*메인뷰*/

/*버튼*/
#button {
	width: 750px;
	margin: 0 auto;
}

/*서치창*/
#search_list {
	margin-top: 10px;
}

/*메인 공지 뿌려주는 곳*/
.gonji {
	width: 900px;
	margin: 0 auto;
	text-align: center;
	border-bottom: 1px solid #dddddd;
	vertical-align: middle;
	padding-top: 7px;
	padding-bottom: 7px;
	font-size: 9pt;
	background-color: #F6F6F6;
	
}



.gonji a:hover {
	text-decoration: underline;
	
}

.gonji_part {
	width: 10%;
	display: inline-block;
	
	vertical-align: middle;
}

.gonji_main {
	width: 40%;
	display: inline-block;
	
	/*overflow: hidden;*/
	white-space: nowrap; /*줄바뀜 없음*/
	overflow: hidden; /*정해진 크기만큼 보인다.*/
	text-overflow: ellipsis; /*긴 문장을 줄여준다*/
	vertical-align: middle; /*세로길이를 중앙으로 정렬*/
}

.gonji_mid {
	vertical-align: middle;
	width: 10%;
	
	display: inline-block;
}

.gonji_view_click {
	vertical-align: middle;
	width: 10%;
	
	display: inline-block;
}

.gonji_date {
	width: 20%;
	display: inline-block;
	
	vertical-align: middle;
}

#main_style_text {
	/*padding-top : 5px;*/
	text-decoration: none;
	
	font-weight : bold;
	color : black;
}

#main_style_text:hover {
	text-decoration: underline;
}

/*게시글을 뿌려주는 곳.*/
.view {
	width: 900px;
	margin: 0 auto;
	text-align: center;
	border-bottom: 1px solid #dddddd;
	vertical-align: middle;
	padding-top: 7px;
	padding-bottom: 7px;
	font-size: 9pt;
	/*margin-bottom: 5px;*/
}

.view_gubun {
	width: 10%;
	display: inline-block;
	vertical-align: middle;
}

.view_main {
	width: 40%;
	display: inline-block;
	/*overflow: hidden;*/
	white-space: nowrap; /*줄바뀜 없음*/
	overflow: hidden; /*정해진 크기만큼 보인다.*/
	text-overflow: ellipsis; /*긴 문장을 줄여준다*/
	vertical-align: middle; /*세로길이를 중앙으로 정렬*/
}

.view a:hover {
	text-decoration: underline;
	color: white;
}

.view_mid {
	vertical-align: middle;
	width: 10%;
	display: inline-block;
}

.view_peo_view {
	vertical-align: middle;
	width: 10%;
	display: inline-block;
}

.view_date {
	width: 20%;
	display: inline-block;
	vertical-align: middle;
}
/*Overflow 해결...*/
#style_text {
	/*padding-top : 5px;*/
	text-decoration: none;
	color: black;
}

#style_text:hover {
	text-decoration: underline;
}
/*페이지 이동 총 10개로 뿌림*/
#page_move {
	padding-top: 10px;
	
	width: 900px;
	margin: 0 auto;
	font-size: 11pt;
}
#page_move a{
	color : black;
	text-decoration : none;
}
#page_move a:hover{
	text-decoration: underline;

}

/*버튼*/
#insert{
	background-color: #dddedf;
	border: 1px solid #dddedf;
	cursor : pointer;
	width : 80px;
	height : 30px;
	font-weight: bold;
}
#fi{
	width : 200px;
}
#fi2{
	background-color: #dddedf;
	border: 1px solid #dddedf;
	width : 60px;
	height : 30px;
	cursor : pointer;
	font-weight: bold;
}

/*각 게시판 배너*/
#banner_gonji{
	margin : 0 auto;
	background-image : url(./board/images/noti.jpg);
	background-repeat : no-repeat;
	width : 900px;
	height : 40px;
	margin-top : 20px;
	margin-bottom: 10px;
}
#banner_salutation_team{
	margin : 0 auto;
	background-image : url(./board/images/hr.jpg);
	background-repeat : no-repeat;
	width : 900px;
	height : 40px;
	margin-top : 20px;
	margin-bottom: 10px;
}
#banner_programmer_team{
	margin : 0 auto;
	background-image : url(./board/images/devel.jpg);
	background-repeat : no-repeat;
	width : 900px;
	height : 40px;
	margin-top : 20px;
	margin-bottom: 10px;
}
#banner_manager_team{
	margin : 0 auto;
	background-image : url(./board/images/general.jpg);
	background-repeat : no-repeat;
	width : 900px;
	height : 40px;
	margin-top : 20px;
	margin-bottom: 10px;
}
#banner_promote_team{
	margin : 0 auto;
	background-image : url(./board/images/promotion.jpg);
	background-repeat : no-repeat;
	width : 900px;
	height : 40px;
	margin-top : 20px;
	margin-bottom: 10px;
}
#banner_proposal_team{
	margin : 0 auto;
	background-image : url(./board/images/recom.jpg);
	background-repeat : no-repeat;
	width : 900px;
	height : 40px;
	margin-top : 20px;
	margin-bottom: 10px;
}
/*라벨*/


</style>
</head>
<body>
	<jsp:useBean id="boardVo" class="Board.BoardVo" />
	<jsp:setProperty property="*" name="boardVo" />
	<%
		//파트
			String part = (String)session.getAttribute("part");
			String id = (String)session.getAttribute("Mid");
			
			/* session.setAttribute("part", part); */
			String part2 = boardVo.getBo_part();
			/* 
			if(boardVo.getText_find() != null){
				session.setAttribute("text_find", boardVo.getText_find());
			}
			if(boardVo.getFind() != null){
				session.setAttribute("find", boardVo.getFind());
			}
			 */
			int aaa = Integer.parseInt(request.getParameter("nowPage"));
			
			BoardMyba board = new BoardMyba();
			
			
			board.setVo(boardVo);
			board.setNowPage(Integer.parseInt(request.getParameter("nowPage")));
			ArrayList<BoardVo> lists = board.list();
			ArrayList<BoardVo> mlist = board.mlist();
	%>
	
	<%if(part2.equals("공지사항")){ %>
		<div id = 'banner_gonji'></div>
	<%}else if(part2.equals("인사팀")){ %>
		<div id = 'banner_salutation_team'></div>
	<%}else if(part2.equals("개발팀")){ %>
		<div id = 'banner_programmer_team'></div>
	<%}else if(part2.equals("총무팀")){ %>
		<div id = 'banner_manager_team'></div>
	<%}else if(part2.equals("홍보팀")){ %>
		<div id = 'banner_promote_team'></div>
	<%}else if(part2.equals("건의사항")){ %>
		<div id = 'banner_proposal_team'></div>
	<%} %>
	
	<form name = 'paging' method = 'post'>
	<input type = 'hidden' name = 'nowPage' value = '<%=board.getNowPage() %>'>
	<div id='board_view'>
		<div id='board_gubun'>구분</div>
		<div id='board_main'>제목</div>
		<div id='board_mid'>작성자</div>
		<div id='board_peo_view'>조회수</div>
		<div id='board_date'>작성일</div>
	</div>

	<%
		for(int j = 0; j<mlist.size(); j++){
			BoardVo vo1 = mlist.get(j);
	%>
	<div class='gonji'>
		<div class='gonji_part'><%=vo1.getBo_part()%></div>
		<div class='gonji_main'>
			<a
				href="#" onclick = "gonji_li('<%=vo1.getBo_no()%>','<%=vo1.getBo_part()%>','<%=board.getNowPage() %>')"
				id='main_style_text'><%=vo1.getBo_title()%></a>
		</div>
		<div class='gonji_mid'><%=vo1.getSa_nm()%></div>
		<div class='gonji_view_click'><%=vo1.getBo_clicks()%></div>
		<%
			SimpleDateFormat main = new SimpleDateFormat("yyyy/MM/dd");
				//시간을변환하는 simpledataformat
		%>
		<div class='gonji_date'><%=main.format(vo1.getRg_dt())%></div>
	</div>
	<%
		}
	%>

	<%
		for(int i=0; i<lists.size(); i++){
			BoardVo vo = lists.get(i);
	%>
	<div class='view'>
		<div class='view_gubun'><%=vo.getBo_part()%></div>
		<div class='view_main'>
			<a href="#"
				onclick="view('<%=vo.getBo_no()%>','<%=vo.getBo_part()%>','<%=board.getNowPage() %>')"
				id='style_text'><%=vo.getBo_title()%></a>
		</div>
		<div class='view_mid'><%=vo.getSa_nm()%></div>
		<div class='view_peo_view'><%=vo.getBo_clicks()%></div>
		<%
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
				//시간을변환하는 simpledataformat
		%>
		<div class='view_date'><%=sdf.format(vo.getRg_dt())%></div>
	</div>
	<%
		}
	%>
	<!--  <div id = 'board_bottom'></div>-->
	
	<!-- 페이징 -->
	<div id='page_move' align="center">
		<%
			if(board.getNowBlock()>1){
		%>
		<a href='#' onclick="goPage('<%=boardVo.getBo_part()%>','<%=board.getStartPage()-1%>')">◀</a>
		<%
			}
		%>
		<%
			for(int i= board.getStartPage(); i<=board.getEndPage(); i++){
				if(i == board.getNowPage()){
		%>
		<a href="#" onclick="goPage('<%=boardVo.getBo_part() %>','<%=i %>')"><font color="#9acd66" style="font-weight: bold;">
		<%=i%></font></a>
		<%
		}else{%>
			<a href="#" onclick="goPage('<%=boardVo.getBo_part() %>','<%=i %>')"><%=i%></a>
		<%}
	}
		%>
		<%if(board.getNowBlock() < board.getTotBlock()){ %>
		  
		<a href='#' onclick="goPage('<%=boardVo.getBo_part() %>',<%=board.getEndPage()+1%>)">▶ </a>
		<%} %>
		
	</div>
	<div id='button' align="right">
	
		<%if(id.equals("1408M001")){ %>
				<input type='button' value='글쓰기' id='insert' onclick = "PageWrite('<%=boardVo.getBo_part() %>')">
		<%}else{ %>
			<%if(!part2.equals("공지사항")){ %>
				<input type='button' value='글쓰기' id='insert' onclick = "PageWrite('<%=boardVo.getBo_part() %>')">
			<%} %>
			
		<%} %>
		
	</div>
	<div id='search_list' align="center">
		
		
		 <input type='search' name='text_find' id='fi' value="<%=boardVo.getText_find()%>"
		 placeholder="제목 또는 내용을 입력하세요."> <input
			type='submit' value='검색'
			onclick="search('<%=boardVo.getBo_part() %>','<%=board.getStartPage()%>')" id = 'fi2'>
	</div>
	</form>	
</body>
</html>